var http = require('http');
var url = require('url');
var router = require('./models/router');
http.createServer(function (request, response) {
  if(request.url !== "/favicon.ico") {
    pathname = url.parse(request.url).pathname;
    pathname = pathname.replace(/\//,'');
    try {
      router[pathname](request, response);
    } catch(err) {
      console.log('aaa='+err);
      response.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
      response.write(err.toString());
      response.end();
    }
    console.log('server执行完毕');
  }
}).listen(8000);
console.log('Server running at http://127.0.0.1:8000');
